<?php
if (! defined ( 'IN_BIC' )) {
	die ( '非法View访问来源!' );
}
/**
 *
 * @package Bic
 * @author Bic
 * @version $Id: BicSqli.php 2012年3月30日 16时49分00秒
 * @copyright (c) 2012 Bic
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 *
 * Minimum Requirement: PHP 5.2.x
 */
class Bic_View_Helper_Form extends Bic_Base {
    public function create($option){
        return "<form {$this->_parseOption($option)}>";
    }
    public function end(){
        return "</form>";
    }
    public function input($type,$name,$option=array()){
        return "<input name=\"{$name}\" type=\"{$type}\" {$this->_parseOption($option)}/>";
    }
    public function text($name,$option){
        return $this->input('text', $name, $option);
    }
    public function checkbox($name,$option){
        return $this->input('checkbox', $name, $option);
    }
    public function radio($name,$option){
        return $this->input('text', $name, $option);
    }
    public function file($name,$option){
        return $this->input('text', $name, $option);
    }
    public function textarea($name,$option){
        return "<textarea name=\"{$name}\" {$this->_parseOption($option)}></textarea>";
    }
    public function select($name,$option=array()){
        return "<input name=\"{$name}\" ". $this->_parseOption($option) ."/>";
    }
    //解析参数
    protected function _parseOption($option){
        $eleOption = array();
        foreach ($option as $key => $val){
            $val = str_replace('"','\"',$val);
            $eleOption[] = "{$key}=\"{$val}\"";
        }
        return join(" ", $eleOption);
    }
}

